package com.longcai.controller.nearby;


import com.alibaba.fastjson.JSONObject;
import com.longcai.bean.ApiResult;
import com.longcai.service.nearby.ClyjNearbyGoodsTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 附近商品类型 前端控制器
 * </p>
 *
 * @author ZJ
 * @since 2019-03-26
 */
@Controller
@RequestMapping("/clyjNearbyGoodsType")
public class ClyjNearbyGoodsTypeController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private ClyjNearbyGoodsTypeService clyjNearbyGoodsTypeService;


    /**
     * 查询店铺商品类型
     *
     * @param params
     * @return
     */
    @RequestMapping("/getShoptype")
    @ResponseBody
    public ApiResult getShoptype(@RequestBody JSONObject params) {
        String shopsid = params.getString("shopsid");
        if (shopsid.equals("") || shopsid == null) {
            return ApiResult.fail("查询失败");
        }
        return this.clyjNearbyGoodsTypeService.getShoptype(shopsid);
    }

    /**
     * 查询店铺商品类型对应商品
     *
     * @param params
     * @return
     */
    @RequestMapping("/getShopsGoods")
    @ResponseBody
    public ApiResult getShopsGoods(@RequestBody JSONObject params) {
        String shopsid = params.getString("shopsid");
        String type = params.getString("type");
        if (shopsid.equals("") || shopsid == null) {
            logger.error("查询失败");
            return ApiResult.fail("查询失败");
        }
        if (type.equals("") || type == null) {
            logger.error("查询失败");
            return ApiResult.fail("查询失败");
        }
        return this.clyjNearbyGoodsTypeService.getShopsGoods(shopsid, type);
    }

    /**
     * 获取行业类型
     * @param params
     * @return
     */
    @RequestMapping("/getShopsGoodsByArea")
    @ResponseBody
    public ApiResult getShopsGoodsByArea(){
       return this.clyjNearbyGoodsTypeService.getShopsGoodsByArea();
    }
}

